<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>3dchess: Negamax&lt; TGameState, AB_CUTOFF_ENABLED, MOVE_ORDERING_ENABLED, TRANSPOSITION_TABLES_ENABLED &gt; Class Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">3dchess
   </div>
   <div id="projectbrief">Basic chess application with OpenGL graphics and AI</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-attribs">Public Attributes</a> &#124;
<a href="#pri-methods">Private Member Functions</a> &#124;
<a href="#pri-attribs">Private Attributes</a> &#124;
<a href="class_negamax-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">Negamax&lt; TGameState, AB_CUTOFF_ENABLED, MOVE_ORDERING_ENABLED, TRANSPOSITION_TABLES_ENABLED &gt; Class Template Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Implementation of a <a class="el" href="class_negamax.html" title="Implementation of a Negamax algorithm. ">Negamax</a> algorithm.  
 <a href="class_negamax.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="_negamax_8h_source.html">Negamax.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_negamax_1_1_option.html">Option</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Helper class for holding a move option in move ordering.  <a href="class_negamax_1_1_option.html#details">More...</a><br/></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_negamax_1_1_perf_counters.html">PerfCounters</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Structure with performance counters used for debugging and evaluation.  <a href="struct_negamax_1_1_perf_counters.html#details">More...</a><br/></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a68c8b205384caa9099b5f58a960dc13a"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a68c8b205384caa9099b5f58a960dc13a"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_negamax.html#a68c8b205384caa9099b5f58a960dc13a">Negamax</a> ()</td></tr>
<tr class="memdesc:a68c8b205384caa9099b5f58a960dc13a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates a new algorithm instance. <br/></td></tr>
<tr class="separator:a68c8b205384caa9099b5f58a960dc13a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a98943353b28ca48b5a696993fabd8a39"><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct_negamax_result.html">NegamaxResult</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_negamax.html#a98943353b28ca48b5a696993fabd8a39">search</a> (const TGameState &amp;state, size_t maxDepth)</td></tr>
<tr class="memdesc:a98943353b28ca48b5a696993fabd8a39"><td class="mdescLeft">&#160;</td><td class="mdescRight">Search given state up to maxDepth full turns.  <a href="#a98943353b28ca48b5a696993fabd8a39">More...</a><br/></td></tr>
<tr class="separator:a98943353b28ca48b5a696993fabd8a39"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a66184104466386099085c2a434da9b1e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_negamax.html#a66184104466386099085c2a434da9b1e">abort</a> ()</td></tr>
<tr class="memdesc:a66184104466386099085c2a434da9b1e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Aborts the currently running calculation.  <a href="#a66184104466386099085c2a434da9b1e">More...</a><br/></td></tr>
<tr class="separator:a66184104466386099085c2a434da9b1e"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-attribs"></a>
Public Attributes</h2></td></tr>
<tr class="memitem:ab66dfe086e5a286d085ac1ed93bd18bd"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab66dfe086e5a286d085ac1ed93bd18bd"></a>
struct <a class="el" href="struct_negamax_1_1_perf_counters.html">Negamax::PerfCounters</a>&#160;</td><td class="memItemRight" valign="bottom"><b>m_counters</b></td></tr>
<tr class="separator:ab66dfe086e5a286d085ac1ed93bd18bd"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pri-methods"></a>
Private Member Functions</h2></td></tr>
<tr class="memitem:abfb76d2e30818cdaf93d77452cd7135b"><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct_negamax_result.html">NegamaxResult</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_negamax.html#abfb76d2e30818cdaf93d77452cd7135b">search_recurse</a> (TGameState state, size_t depth, const size_t maxDepth, Score alpha, Score beta)</td></tr>
<tr class="memdesc:abfb76d2e30818cdaf93d77452cd7135b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Recursive <a class="el" href="class_negamax.html" title="Implementation of a Negamax algorithm. ">Negamax</a> search with optional Alpha-Beta cutoff.  <a href="#abfb76d2e30818cdaf93d77452cd7135b">More...</a><br/></td></tr>
<tr class="separator:abfb76d2e30818cdaf93d77452cd7135b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a975aeca01f30cba138118127f7c541d2"><td class="memItemLeft" align="right" valign="top">Score&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_negamax.html#a975aeca01f30cba138118127f7c541d2">estimateScoreFor</a> (const TGameState &amp;state, size_t depth) const </td></tr>
<tr class="memdesc:a975aeca01f30cba138118127f7c541d2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Estimates score for given state.  <a href="#a975aeca01f30cba138118127f7c541d2">More...</a><br/></td></tr>
<tr class="separator:a975aeca01f30cba138118127f7c541d2"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pri-attribs"></a>
Private Attributes</h2></td></tr>
<tr class="memitem:aa50b91bcf41b104757eac2751859be79"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa50b91bcf41b104757eac2751859be79"></a>
<a class="el" href="class_transposition_table.html">TranspositionTable</a>&#160;</td><td class="memItemRight" valign="bottom"><b>m_transpositionTable</b></td></tr>
<tr class="separator:aa50b91bcf41b104757eac2751859be79"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6d19d69f8421dd568e1d0aa5448270cb"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a6d19d69f8421dd568e1d0aa5448270cb"></a>
std::atomic&lt; bool &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_negamax.html#a6d19d69f8421dd568e1d0aa5448270cb">m_abort</a></td></tr>
<tr class="memdesc:a6d19d69f8421dd568e1d0aa5448270cb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Abort flag. <br/></td></tr>
<tr class="separator:a6d19d69f8421dd568e1d0aa5448270cb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1079ff846b267633d90d237f9ae66329"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a1079ff846b267633d90d237f9ae66329"></a>
Logging::Logger&#160;</td><td class="memItemRight" valign="bottom"><b>m_log</b></td></tr>
<tr class="separator:a1079ff846b267633d90d237f9ae66329"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><h3>template&lt;typename TGameState = GameState, bool AB_CUTOFF_ENABLED = true, bool MOVE_ORDERING_ENABLED = true, bool TRANSPOSITION_TABLES_ENABLED = true&gt;<br/>
class Negamax&lt; TGameState, AB_CUTOFF_ENABLED, MOVE_ORDERING_ENABLED, TRANSPOSITION_TABLES_ENABLED &gt;</h3>

<p>Implementation of a <a class="el" href="class_negamax.html" title="Implementation of a Negamax algorithm. ">Negamax</a> algorithm. </p>
<dl class="tparams"><dt>Template Parameters</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">TGameState</td><td>Type of game state so <a class="el" href="class_game_state.html" title="Facade class for the game logic, holds the chessboard and the turn generator. ">GameState</a> is mockable. </td></tr>
    <tr><td class="paramname">AB_CUTOFF_ENABLE</td><td>If false Alpha-Beta cutoff feature is disabled. </td></tr>
    <tr><td class="paramname">MOVE_ORDERING_ENABLED</td><td>If false move ordering is disabled. </td></tr>
    <tr><td class="paramname">TRANSPOSITION_TABLES_ENABLED</td><td>If false transposition tables are disabled. </td></tr>
  </table>
  </dd>
</dl>
</div><h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a66184104466386099085c2a434da9b1e"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename TGameState = GameState, bool AB_CUTOFF_ENABLED = true, bool MOVE_ORDERING_ENABLED = true, bool TRANSPOSITION_TABLES_ENABLED = true&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="class_negamax.html">Negamax</a>&lt; TGameState, AB_CUTOFF_ENABLED, MOVE_ORDERING_ENABLED, TRANSPOSITION_TABLES_ENABLED &gt;::abort </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Aborts the currently running calculation. </p>
<p>Call from another thread to abort currently running search. </p>

</div>
</div>
<a class="anchor" id="a975aeca01f30cba138118127f7c541d2"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename TGameState = GameState, bool AB_CUTOFF_ENABLED = true, bool MOVE_ORDERING_ENABLED = true, bool TRANSPOSITION_TABLES_ENABLED = true&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">Score <a class="el" href="class_negamax.html">Negamax</a>&lt; TGameState, AB_CUTOFF_ENABLED, MOVE_ORDERING_ENABLED, TRANSPOSITION_TABLES_ENABLED &gt;::estimateScoreFor </td>
          <td>(</td>
          <td class="paramtype">const TGameState &amp;&#160;</td>
          <td class="paramname"><em>state</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>depth</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">private</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Estimates score for given state. </p>
<p>Used for move ordering. </p>
<dl class="section note"><dt>Note</dt><dd>Assumes state has opponent as next to move. </dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">state</td><td>State to estimate. </td></tr>
    <tr><td class="paramname">depth</td><td>Depth in plies the given state has. Used to penalize deep wins or shallow losses. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Estimated score between WIN_SCORE and LOOSE_SCORE </dd></dl>

</div>
</div>
<a class="anchor" id="a98943353b28ca48b5a696993fabd8a39"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename TGameState = GameState, bool AB_CUTOFF_ENABLED = true, bool MOVE_ORDERING_ENABLED = true, bool TRANSPOSITION_TABLES_ENABLED = true&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="struct_negamax_result.html">NegamaxResult</a> <a class="el" href="class_negamax.html">Negamax</a>&lt; TGameState, AB_CUTOFF_ENABLED, MOVE_ORDERING_ENABLED, TRANSPOSITION_TABLES_ENABLED &gt;::search </td>
          <td>(</td>
          <td class="paramtype">const TGameState &amp;&#160;</td>
          <td class="paramname"><em>state</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>maxDepth</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Search given state up to maxDepth full turns. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">state</td><td>Game state to search. </td></tr>
    <tr><td class="paramname">maxDepthInTurns</td><td>Number of full turns (ply and return ply) to search. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Result of the search. </dd></dl>

</div>
</div>
<a class="anchor" id="abfb76d2e30818cdaf93d77452cd7135b"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename TGameState = GameState, bool AB_CUTOFF_ENABLED = true, bool MOVE_ORDERING_ENABLED = true, bool TRANSPOSITION_TABLES_ENABLED = true&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="struct_negamax_result.html">NegamaxResult</a> <a class="el" href="class_negamax.html">Negamax</a>&lt; TGameState, AB_CUTOFF_ENABLED, MOVE_ORDERING_ENABLED, TRANSPOSITION_TABLES_ENABLED &gt;::search_recurse </td>
          <td>(</td>
          <td class="paramtype">TGameState&#160;</td>
          <td class="paramname"><em>state</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>depth</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const size_t&#160;</td>
          <td class="paramname"><em>maxDepth</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Score&#160;</td>
          <td class="paramname"><em>alpha</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Score&#160;</td>
          <td class="paramname"><em>beta</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">private</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Recursive <a class="el" href="class_negamax.html" title="Implementation of a Negamax algorithm. ">Negamax</a> search with optional Alpha-Beta cutoff. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">state</td><td>Game state to search from. </td></tr>
    <tr><td class="paramname">depth</td><td>Depth in plys already searched. </td></tr>
    <tr><td class="paramname">maxDepth</td><td>Maximum depth in plys to search. </td></tr>
    <tr><td class="paramname">alpha</td><td>Minimum score current (maximizing) player is assured of </td></tr>
    <tr><td class="paramname">beta</td><td>Maximum score enemy (minimizing) player is assured of </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>S:/dev/3dchess/src/ai/<a class="el" href="_negamax_8h_source.html">Negamax.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Sun Mar 9 2014 23:13:00 for 3dchess by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.6
</small></address>
</body>
</html>
